<script>

var user = false;
var pedido = false;
var userId = false;
var edpedido = "";
var vsrc = 130;

function moveDown(id)
{
	var scrtop = document.getElementById(id).scrollTop;

	document.getElementById(id).scrollTop = scrtop + vsrc;
}

function moveUp(id)
{
	var scrtop = document.getElementById(id).scrollTop;

	document.getElementById(id).scrollTop = scrtop - vsrc;
}

function habilitaMenu()
{
	$(".menu_login").animate({opacity: 1}, 10, function(){});
}

function desabilitaMenu()
{
	$(".menu_login").animate({opacity: 0.5}, 800, function(){});

	$(".menu_home").click();

	$(".stoq").hide();
	$(".relat").hide();

	return true;
}

function closePedido(id)
{
	idDisablePedido = id;
	
	$(".bg_transp").show();

	$.post('pedido/list', {cod: id}, function(res)
	{
		$("#resumList").html(res);
		$(".resumDiv").fadeIn("fast");
	});
}

function msg(json)
{
	var time = json.time;
	
	$("#msg").css("color", "#0F0F0F").css("fontWeight", "normal");
	
	if(json.type == "alert")
	{
		$("#msg").css("color", "red").css("fontWeight", "bold");
	}
	if(!json.time)
	{
		time = 3000;
	}
	
	$("#msg").html(json.vmsg).fadeIn();

	setTimeout(function(obj) { $("#msg").fadeOut(); }, time, this);
}

function mostrarFormaPagamento()
{
	$.post('pedido/formas-pagamento', {numeroMesa: lastClick}, function(html){
		$("#ajax-formas-pagamento").html(html);
	});
}

function hideMsg()
{
	$("#msg").fadeOut();
}

$(function(){
	$(".stoq").hide();
	$(".relat").hide();
	
	$("#mainMenu div").click(function()
	{
		if(pedido)
		{
			if(confirm("Deseja deletar o pedido?"))
			{
				pedido = false;
				
				$.post('pedido/deletes', {cod_pedido: cod_item}, function(req){});
			}
			else
			{
				return;
			}
		}

		//$(".date").datepicker({dateFormat: 'dd/mm/yy', showAnim: 'fadeIn', yearRange: '2000:2040'});

		if($(this).attr("id") == "menu_logoff")
		{
			return;
		}
		
		if(!user)
		{
			//msg({vmsg: "Nenhum usuario logado.", time: 3000});

			return false;
		}
		
		$("#mainMenu div").css("background", "none").removeClass("selected_menu").addClass("menu_normal");
		$("#menu_logoff").css("background", "#EF9200");
		$(this).css("background", "white").removeClass("menu_normal").addClass("selected_menu");

		//$("#blank_scr").fadeIn("fast");
		$("#content").hide();

		$("#menu_cnew").click(function(){
			$("#userNumberTxt").focus();
		});

		esconderKeyboard();
		keybnumHide();

		if('pedido/ajaxlistall' == $(this).attr("id") || 
				'pedido/ajaxlistall-fechar' == $(this).attr("id"))
		{
			$.post($(this).attr("id"), {user_id: user.caf01_cod, gerente: user.caf01_admin}, function(rs)
			{
				$("#content").html(rs);
				
				//$("#blank_scr").fadeOut("fast");
				$("#content").show();
		
				$("#labelUserLogin").html(auxJson.caf01_user);
			});
		}else{

		$.ajax({
			url     : $(this).attr("id"),
			success : function(result){
				$("#content").html(result);
				
				//$("#blank_scr").fadeOut("fast");
				$("#content").show();
			}
		});
}
		
	});
});
</script>

<style>

#mainMenu div:hover{
	cursor: pointer;
}

.selected_menu{
	border-top: 2px solid #EF9200;
	border-left: 2px solid #EF9200;
	border-right: 2px solid #EF9200;
	height: 50px;
}

.menu_normal{
	//border-right: 1px solid white;
	color: white;
}


</style>

<div id="blank_scr" style="display: none; text-align: center; width: 200px; z-index: 1000; left: 50%; margin-left: -100px; position: fixed; top: 55%; margin-top: -100px; padding: 10px; opacity: 0.95;">
	<img style="margin-top: 20%;" src="public/images/ajax-loader.gif" alt="" />
	<br />
	Carregando
</div>

<div class="bg_transp" style="display: none; z-index: 2; position: fixed; width: 100%; height: 100%; opacity: 0.8; background-color: white;  top: 0; left: 0;"></div>

<div id="mainMenu" style="height: 70px; background-color: #FF9900; 
border-bottom: 2px solid #EF9200; position: fixed; top: 0; width: 100%;">
	<div style="position: absolute; top: 7px; left: 15px;">
	</div>
	<div id="menu_logoff" onclick="logoff();" class="menu_normal menu_login" style="height: 52px; opacity: 0.5; 
	padding: 10px; text-align: center; float: right; font-weight: bold; width: 30px;  background-color: orange;">
		<img style="margin-top: 13px;margin-left: 5px;" src="public/images/shut.png" />
		<br />
		SAIR
	</div>
	<div class="bt_usuario menu_normal menu_login relat" id="admin" 
	style="height: 52px; opacity: 0.5; padding: 10px; text-align: center; float: right; font-weight: bold; 
	width: 100px;border:0;width: 30px;background: orange;">
		<img width="16px" style="margin-top: 13px;margin-left: 5px" src="public/images/actions/lock.png" />
		<br />
		<font style="font-family: arial;">ADM </font>
	</div>

	<div id="index/home" class="selected_menu menu_home" style="padding: 10px; 
	height: 52px; text-align: center;float:left; margin-left: 10px;font-weight: bold; border: 0; z-index:999;
	width: 100px;background: white;">
		<img src="public/images/actions/home.png" />
		<br />
		<font style="font-family: arial;">Home</font>
	</div>
	<div class="menu_cnew menu_normal menu_login" id="pedido/new" style="padding: 10px; opacity: 0.5; 
	height: 52px; text-align: center; font-weight: bold;float:left; width: 100px; border: 0;">
		<img src="public/images/actions/record.png" />
		<br />
		<font style="font-family: arial;">Novo Pedido</font>
	</div>
	<div class="bt_list_todos menu_normal menu_login" id="pedido/listtodos" style="height: 52px; opacity: 0.5; 
	padding: 10px; text-align: center; float: left; font-weight: bold; width: 100px;border: 0;">
		<img src="public/images/actions/tw.png" />
		<br />
		<font style="font-family: arial;">Pedidos</font>
	</div>
	<div onclick="ajaxPar('ajaxlistall');" class="bt_list_pedido menu_normal menu_login" id="pedido/ajaxlistall" 
	style="height: 52px; opacity: 0.5; padding: 10px; text-align: center; float: left; 
	font-weight: bold; width: 100px;border: 0;">
		<img src="public/images/actions/list.png" />
		<br />
		<font style="font-family: arial;">Mesas</font>
	</div>
	<div class="bt_fechar_mesa menu_normal menu_login" id="pedido/ajaxlistall-fechar" style="height: 52px;
	 opacity: 0.5; padding: 10px; text-align: center; float: left; font-weight: bold; width: 100px;border: 0;">
		<img src="public/images/actions/stop.png" />
		<br />
		<font style="font-family: arial;">Fechar Mesa</font>
	</div>
</div>
<div style="height: 70px;"></div>

<?php echo $this->render("helpers/resumo.phtml"); ?>
<?php echo $this->render("helpers/keyboard.phtml"); ?>
<?php echo $this->render("helpers/keybnum.phtml"); ?>

<div id="ajax-formas-pagamento"></div>

<div id="msg" class="ui-corner-all" style="z-index: 1001; background-color: #FFEF3F; border: 2px solid #EFE03B; padding: 20px 0px 22px 0; color: #0F0F0F; position: fixed; top: 80px; opacity: 0.9; right: 10px; width: 250px; display: none; text-align: center;">
		Salvo com sucesso.
</div>